package com.jn.erp.security.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("t_sys_user")
@NoArgsConstructor
public class SysUser implements Serializable {
    @TableId(
            value = "id",
            type = IdType.AUTO
    )
    private Long id;
    private String name;
    private String email;
    @TableField(
            updateStrategy = FieldStrategy.IGNORED
    )
    private Long wxAccessId;
    private Integer gender;
    private String mobile;
    private Boolean state;
    private String password;
    //头像
    private String avatar;

    private String remark;
    private Integer loginTimes;

    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm"
    )
    private LocalDateTime latestLoginTime;
    private String latestLoginIp;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm"
    )
    private LocalDateTime addTime;
    @ApiModelProperty("所属学校id")
    private Long schoolId;

    @ApiModelProperty("创建者所属组织ID")
    private Long orgId;


    @TableField(exist = false)
    private Long roleId;

    @TableField(exist = false)
    private List<SysRole> roles;

    /** 角色组 */
    @TableField(exist = false)
    private Long[] roleIds;

    public SysUser(Long id, Long orgId) {
        this.id = id;
        this.orgId = orgId;
    }

    //昵称
    @TableField(exist = false)
    private String nickName;
}
